// pages/card/card.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    TabCur:0,
    page:1,
    navList:[],
    items:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.loadCate();
    this.load();
  },
  tabSelect(e) {
    this.setData({
      TabCur: e.currentTarget.dataset.id,
      page:1,
      items:[]
    })
    this.load();
  },
  toDetail(e){
    wx.navigateTo({
      url: '/pages/card/detail?id='+e.currentTarget.dataset.id,
    })
  },
  async loadCate(){
    let res=await wx.util.post("card/cate");
    this.setData({
      navList: res.data
    })
  },
  async load(){
    let res=await wx.util.post("card/index",{page:this.data.page,cate:this.data.TabCur});
    wx.stopPullDownRefresh();
    this.setData({
      items: res.data
    })
  },

  onShareTimeline: function (e) {
    let wxid=wx.getStorageSync("openid") || '';
    return {
      query: 'wxid='+wxid,
    }
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    let wxid=wx.getStorageSync("openid") || '';
    return {
      path: '/pages/card/card?wxid='+wxid,
    }
  }
})